package com.github.postsanf.yinian.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;

import com.github.postsanf.yinian.BaseActivity;
import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.widget.MyJCVideoPlayerStandard;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;

public class StealCourseVideoActivity extends BaseActivity {
    private MyJCVideoPlayerStandard videoView;
    private ProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_stealcourse_video);
        setContentView(R.layout.activity_edit_videopreview);
        initView();
    }

    private void initView() {
//        String videoUrl1 = "http://o9im0tspz.bkt.clouddn.com/%E5%8A%A8%E6%95%88~2.mp4";
        //网络视频
        String videoUrl2 = "http://o9im0tspz.bkt.clouddn.com/%E5%81%B7%E5%9B%BE%E4%BB%8B%E7%BB%8D.mp4";
        videoView = (MyJCVideoPlayerStandard) this.findViewById(R.id.videoView);
        videoView.setUp(videoUrl2, "");
        videoView.ivStart.performClick();
        videoView.ivFullScreen.setVisibility(View.GONE);
//        String videoUrl3 = "android.resource://" + getPackageName() + "/" + R.raw.stealcourse;
//        Uri uri = Uri.parse(videoUrl2);
//        progressBar = (ProgressBar) findViewById(R.id.videoView_par);
//        videoView = (VideoView) this.findViewById(R.id.videoView);
//        videoView.setMediaController(new MediaController(this));
//        MediaController mc = new MediaController(this);
//        mc.setVisibility(View.INVISIBLE);
//        videoView.setMediaController(mc);
//        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
//
//            @Override
//            public void onPrepared(MediaPlayer mp) {
//                progressBar.setVisibility(View.GONE);
//            }
//        });
//        videoView.setOnCompletionListener(new MyPlayerOnCompletionListener());
//        videoView.setVideoURI(uri);
//        videoView.start();
    }

//    class MyPlayerOnCompletionListener implements MediaPlayer.OnCompletionListener {
//
//        @Override
//        public void onCompletion(MediaPlayer mp) {
//            Toast.makeText(StealCourseVideoActivity.this, "演示完成", Toast.LENGTH_SHORT).show();
//        }
//    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        if (getIntent() != null && getIntent().getBooleanExtra("fromPerssion", false)) {
            finish();
        } else {
            startActivity(new Intent(StealCourseVideoActivity.this, StealEachPerssionActivity.class));
            finish();
        }
    }


    @Override
    protected void onDestroy() {
        JCVideoPlayer.releaseAllVideos();
        super.onDestroy();
    }

}
